package com.bw.gmall.realtime.dws.function;

import com.bw.gmall.realtime.dws.util.IkUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.util.Set;

/**
 * @Author sw
 * @CreateTime 2024-11-19
 */

@FunctionHint(output = @DataTypeHint("ROW<word STRING>"))
public class KwSplit extends TableFunction<Row> {

    public void eval(String str) {
        Set<String> words = IkUtil.split(str);
        for (String word : words) {
            collect(Row.of(word));
        }
    }
}
